<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>欢迎登录</title>
  <style>
    body {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      background: url('') no-repeat center center fixed;
      background-size: cover;
      font-family: Arial, sans-serif;
    }
    .login-container {
      background: rgba(255, 255, 255, 0.8);
      padding: 20px;
      border-radius: 8px;
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }
    .login-container h2 {
      margin-bottom: 20px;
      color: #333;
    }
    .login-container input {
      width: 100%;
      padding: 10px;
      margin: 10px 0;
      border: 1px solid #ccc;
      border-radius: 4px;
    }
    .login-container input[type="submit"] {
      background-color: #41d7ea;
      color: white;
      border: none;
      cursor: pointer;
    }
    .login-container input[type="submit"]:hover {
      background-color: #21a3c2;
    }
    a {
      text-decoration: none;
    }
  </style>
  <script>
    // 显示消息的函数
    function showMessage(message) {
      if (message) {
        alert(message);
      }
    }
  </script>
</head>
<body>

<div class="login-container">
  <h2>用户登录</h2>
  <form method="post">
    <input type="text" id="user" name="user" placeholder="账&nbsp;&nbsp;&nbsp;号" required>
    <input type="password" id="pass" name="pass" placeholder="密&nbsp;&nbsp;&nbsp;码" required>
    <input type="submit" value="登录">
  </form>
  <a href="/register">没有账号？去注册</a>
</div>
<script>
  // 检查 URL 中的消息参数
  const urlParams = new URLSearchParams(window.location.search);
  const message = urlParams.get('message');
  let alertMessage;

  // 根据不同的消息显示不同的提示
  switch (message) {
    case 'invalid':
      alertMessage = '用户名或密码错误';
      break;
    case 'success':
      alertMessage = '注册成功，请登录';
      break;
    case 'exists':
      alertMessage = '用户已存在，请选择其他用户名';
      break;
    case 'error':
      alertMessage = '发生错误，请稍后重试';
      break;
    default:
      alertMessage = null;
  }

  showMessage(alertMessage);
</script>
</body>
</html>